package fr.insta.psape.dao;

/**
 *
 * @author Sterio
 */
public class FactoryDao {

    public FactoryDao() {
    }
    
    public static IDao<?> getDAO(Object objet) {

        String className = "modele.dao.Dao" + objet.getClass().getSimpleName();

        Class<?> cl;
        Object o = null;

        try {
            cl = Class.forName(className);
            o = cl.newInstance();

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();

        }
        return (IDao<?>) o;
    }
    public static IDao<?> getDAO(String classe) {

        String className = "modele.dao.Dao"+classe;

        Class<?> cl;
        Object o = null;

        try {
            cl = Class.forName(className);
            o = cl.newInstance();

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
            e.printStackTrace();

        }
        return (IDao<?>) o;
    }

}